<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('用户数据库')"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-userDatabase-edit" th:object="${tmdUserDatabase}">
        <input name="userDatabaseId" th:field="*{userDatabaseId}" type="hidden">
        <input name="databaseId" th:field="*{databaseId}" id="databaseId" type="hidden">

        <div class="form-group">
            <label class="col-sm-3 control-label">数据库名称：</label>
            <div class="col-sm-8">
                <input th:field="*{database.databaseName}" class="form-control" disabled type="text">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">别名：</label>
            <div class="col-sm-8">
                <input name="alias" th:field="*{alias}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">状态：</label>
            <div class="col-sm-8">
                <select name="status" disabled class="form-control m-b" th:with="type=${@dict.getType('database_user_status')}" required>
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}"  th:value="${dict.dictValue}" th:field="*{status}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">备注：</label>
            <div class="col-sm-8">
                <input name="remark" th:field="*{remark}" class="form-control" type="text">
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var prefix = ctx + "datamonitor/myUserDatabase";
    $("#form-userDatabase-edit").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            debugger
            $.operate.save(prefix + "/edit", $('#form-userDatabase-edit').serialize());
        }
    }

    // 选择用户
    function selectUsersToCallBack() {
        var options = {
            title: '选择用户',
            url: ctx + "common/modal/parent/sysUser",
            callBack: selectUsers2Submit
        };
        $.modal.openOptions(options);
    }

    function selectUsers2Submit(index, layero) {
        var body = $.modal.getChildFrame(index);
        $("#userId").val(body.find('#userId').val());
        $("#tmpUserId").val(body.find('#userId').val());
        $("#userName").val(body.find('#userName').val());
        $.modal.close(index);
    }
</script>
</body>
</html>